package org.quickstart.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.*;

/**
 * @author Yoav Aharoni
 */
public class PhoneBookView extends Composite implements PhoneBookPresenter.Display {
	private static final Binder binder = GWT.create(Binder.class);

	@UiField
	protected Label editContactLabel;

	@UiField
	protected TextBox nameField;

	@UiField
	protected TextBox phoneField;

	@UiField
	protected Button updateContactButton;

	@UiField
	protected Button testRpcButton;

	@UiField
	protected ListBox contactsListBox;

	public PhoneBookView() {
		final Panel panel = binder.createAndBindUi(this);
		initWidget(panel);
	}

	@Override
	public Widget asWidget() {
		return this;
	}

	@Override
	public void startProcessing() {
	}

	@Override
	public void stopProcessing() {
	}

	@Override
	public HasClickHandlers getTestRpcButton() {
		return testRpcButton;
	}

	@Override
	public HasClickHandlers getUpdateContactButton() {
		return updateContactButton;
	}

	@Override
	public HasText getEditContactLabel() {
		return editContactLabel;
	}

	@Override
	public HasValue<String> getNameField() {
		return nameField;
	}

	@Override
	public HasValue<String> getPhoneField() {
		return phoneField;
	}

	@Override
	public ListBox getContactListBox() {
		return contactsListBox;
	}

	@UiTemplate("PhoneBookView.ui.xml")
	public static interface Binder extends UiBinder<Panel, PhoneBookView> {
	}
}
